﻿using System.Linq;
using System.Web;
using System.Web.Mvc;
using Inscriptionem.Localization;

namespace Inscriptionem.Controllers.Base
{
    public abstract class BaseController : Controller
    {
        protected override IActionInvoker CreateActionInvoker()
        {
            var language = Request.RequestContext.RouteData.Values["language"];
            if (language != null && !Language.AllowedValues.Any(l => l.Name.ToLower() == ((string)language).Trim().ToLower()))
            {
                throw new HttpException(404, "Not found!");
            }

            return base.CreateActionInvoker();
        }
    }
}
